<?php 
	header('Content-type:text/html;charset=utf-8');
	if($_POST){
		$num1=floatval($_POST['num1']);
		$num2=floatval($_POST['num2']);
		$fh=$_POST['fh'];
		switch ($fh) {
			case '+':
				$re=$num1+$num2;
				break;
			case '-':
				$re=$num1-$num2;
				break;
			case '*':
				$re=$num1*$num2;
				break;
			default:
				if($num2==0){
					$re=0;
					echo "<script>alert('被除数不能为0')</script>";
				}else{
					$re=$num1/$num2;
				}
				
				break;
		}				
	}else{
		$re=null;
	}
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>	
		<link rel="stylesheet" type="text/css" href="css/index.css"/>	
		<script type="text/javascript" src="js/jquery-1.7.2.min.js">
			
		</script>
		<script type="text/javascript" src="js/index.js">
			
		</script>
	</head>
	<body>
		<form action="" method="post">
			<input type="text" name="num1" id="num1" hidden/>
			<input type="text" name="num2" id="num2" hidden/>
			<input type="text" name="fh" id="fh" hidden/>
			<div class="box">
				<div class="show">
					<span class="phpre">
						<?php echo $re ?>
					</span>
					<span class="jsre">0</span>
				</div>
				<div class="top">
					<input type="button" value="回退" />
					<input type="button" value="清除" />
					<input type="button" value="正负" />
				</div>
				<div class="bottom">
					<div class="left">
						<input type="button" value="1" />
						<input type="button" value="2" />
						<input type="button" value="3" />
						<input type="button" value="4" />
						<input type="button" value="5" />
						<input type="button" value="6" />
						<input type="button" value="7" />
						<input type="button" value="8" />
						<input type="button" value="9" />
						<input type="button" value="0" id="double"/>
						<input type="button" value="." />
					</div>
					<div class="right">
						<div class="fuhao">
							<input type="button" value="+" />
							<input type="button" value="-" />
							<input type="button" value="*" />
							<input type="button" value="/" />
						</div>
						<div class="val">
							<input type="submit" value="=" />
						</div>
					</div>
				</div>			
			</div>
		</form>
	</body>
</html>
